package com.project.web.controller.client;

import com.project.client.domain.MessageEntity;
import com.project.client.service.MessageService;
import com.project.common.annotation.Log;
import com.project.common.core.controller.BaseController;
import com.project.common.core.domain.AjaxResult;
import com.project.common.core.page.TableDataInfo;
import com.project.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("client/message")
public class MessageController extends BaseController {
    @Autowired
    private MessageService service;

    /**
     * 查询留言记录列表
     */
    @PreAuthorize("@ss.hasPermi('client:message:list')")
    @GetMapping("/list")
    public TableDataInfo list(MessageEntity entity) {
        startPage();
        List<MessageEntity> list = service.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 获取留言记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('client:message:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(service.selectById(id));
    }

    /**
     * 删除留言记录
     */
    @PreAuthorize("@ss.hasPermi('client:message:remove')")
    @Log(title = "留言记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(service.delete(ids));
    }
}
